#include "WorkControl.h"
#include "exceptions.hpp"



WorkControl::WorkControl ()
{

}



Ptr< Work > WorkControl::createWorkFromFile (const QString & filePath)
{
  Ptr< QImage > pImage = new QImage ();
  if (!pImage->load (filePath)) // Load fail
    OOPTHROW (FormatNotSupportException)

  Ptr< Document > pNewDoc = new Document (pImage, filePath);
  Ptr< ViewportControl > pNewViewportCtrl = new ViewportControl (
    pNewDoc->getCanvasRegion ());
  Ptr< Work > pNewWork = new Work (pNewDoc, pNewViewportCtrl);
  return pNewWork;
}


